#ifndef BASE_H
#define BASE_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <jansson.h>
struct Register
{
    uint8_t a;
    uint8_t b;
    uint8_t c;
    uint8_t d;
    uint8_t e;
    uint8_t h;
    uint8_t l;
    uint8_t f;
    uint16_t pc;
    uint16_t sp;
    uint64_t m;
    uint64_t t;
};
struct Z80
{
    uint64_t m;
    uint64_t t;
    struct Register reg;
};
struct Memory
{
    /**
     0000	3FFF	16 KiB ROM bank 00	From cartridge, usually a fixed bank
     4000	7FFF	16 KiB ROM Bank 01–NN	From cartridge, switchable bank via mapper (if any)
     8000	9FFF	8 KiB Video RAM (VRAM)	In CGB mode, switchable bank 0/1
     A000	BFFF	8 KiB External RAM	From cartridge, switchable bank if any
     C000	CFFF	4 KiB Work RAM (WRAM)
     D000	DFFF	4 KiB Work RAM (WRAM)	In CGB mode, switchable bank 1–7
     E000	FDFF	Echo RAM (mirror of C000–DDFF)	Nintendo says use of this area is prohibited.
     FE00	FE9F	Object attribute memory (OAM)
     FEA0	FEFF	Not Usable	Nintendo says use of this area is prohibited.
     FF00	FF7F	I/O Registers
     FF80	FFFE	High RAM (HRAM)
     FFFF	FFFF	Interrupt Enable register (IE)
     **/
    uint8_t rom_bank[0x4000];
    uint8_t rom_bank_1[0x4000];
    uint8_t vram[0x2000];
    uint8_t external_ram[0x2000];
    uint8_t working_ram[0x1000];
    uint8_t working_ram_1[0x1000];
    uint8_t echo_ram[0xFE00 - 0xE000];
    uint8_t oam[0xFEA0 - 0xFE00];
    uint8_t nouse[0xFF00 - 0xFEA0];
    uint8_t io[0xFF80 - 0xFF00];
    uint8_t hram[0xFFFF - 0xFF80];
    uint8_t interrupt_enable[0x1];
};
struct Ins
{
    char *op_code;
    char *d_reg1;
    char *s_reg2;
    char *d_mem1;
    char *s_mem2;
    char *d_n;
    char *s_n;
};

struct Flags
{
    char *Z;
    char *N;
    char *H;
    char *C;
};

struct Operand
{
    char *name;
    int bytes;
    bool immediate;
    bool increment;
    bool decrement;
    struct Operand *next;
};
struct Cycles
{
    uint64_t t;
    struct Cycles *next;
};
#endif